A communications network may generally be defined as a collection of computers or computing systems which interact or transmit data between one network device, e.g., client, router, gateway, and another network device, e.g., server. For example, a communications network may comprise a host machine, e.g., server computer on the Internet commonly referred to as a web server, connected to one or more computers commonly referred to as clients via the Internet. The Internet may refer to a network of networks.
The Internet is based upon a suite of communication protocols known as the Transmission Control Protocol/Internet Protocol (TCP/IP) transmission protocol. A network that uses TCP/IP may be referred to as an Internet Protocol (IP) network. In TCP/IP, the standard describes how an Internet-connected computer should break data down into packets for transmission across the network, and how those packets should be addressed so that they arrive at their destination. IP is the connectionless part of the TCP/IP protocol. The TCP specifies how two Internet computers can establish a reliable data link by means of handshaking.
When one network device, e.g., client, attempts to establish a connection with another network device, e.g., server, using the TCP/IP protocol, the network devices exchange connection state information. For example, the state information may include the number of bytes sent/received on that connection. The state information may also include the number of bytes the network device is allowed to transmit prior to receiving an acknowledgment from the receiving network device. This state information may be stored in a data structure called a “transport control block (TCB)” in the receiving network's memory, e.g., random access memory. Each connection may be associated with a particular TCB and each network device may store a table in its memory that includes a listing of TCBs.
As stated above, information may be transmitted over the Internet using a TCP/IP protocol suite or what may be called a “TCP protocol stack.” The TCP protocol stack may reside in the operating system of the network device. Upon the network device receiving a TCP/IP data packet from a transmitting network device to establish a connection, the TCP protocol stack in the receiving network device may search its memory for the TCB associated with that connection. The TCP/IP packet may include in its header a key, or a value stored in a series of bits, that is used by the TCP protocol stack in the receiving network to index or hash into a table in its memory storing TCBs. Upon finding an entry in the table storing TCBs, the TCP protocol stack in the receiving network device identifies a particular TCB in the indexed entry.
If a network device has multiple processes running in parallel (referred to as a multithreaded system), then other threads (processes) in the network device may be processing data packets for the same connection in parallel. If multiple processes access the same TCB, then a process may obtain invalid information. For example, if one process updates the TCB while another parallel process reads the information in that TCB for the same connection, then the parallel process may read invalid information. Consequently, in order to prevent information in the TCB being overwritten or discarded while another parallel process accesses that TCB, the TCP protocol stack “locks” the TCB indexed in the table. “Locking” refers to preventing another process from accessing that TCB.
Once the TCB is locked, the TCP protocol stack reads the TCB. For example, the TCP protocol stack may read the TCB, which contains the expected sequence number, to determine if the received TCP/IP packet was the packet expected to be received. The TCP protocol stack may determine if the received packet was the packet to be received by reading the sequence number in the packet header of the received packet. If the sequence number read in the header of the received packet is the expected sequence number, then the receiving network device received the expected packet. Otherwise, the receiving network device did not receive the expected packet and may re-sequence or wait for the missing packet.
Next, the TCP protocol stack writes to the TCB, such as updating the state information. For example, the TCP protocol stack may update the next sequence number to be received. Further, in the write operation, the TCP protocol stack may update a pointer in the TCB in order to point to the entry in a buffer, referred to as the “data fragment list,” that contains the payload of the received packet. The TCP protocol stack deposits the payload of the received packet in the data fragment list upon receiving the packet.
Next, the TCP protocol stack unlocks the TCB thereby allowing another process to access the TCB. Hence, the TCP protocol stack performs the operations of lock, read, write and unlock.
Once these operations are performed, the TCP protocol stack transmits an acknowledgment to the transmitting network device that the TCP/IP packet had been received. The TCP protocol stack may further transmit a notification to an application (“TCP application”) in the receiving network device to read the data in the payload of the received packet. Along with the notification may include an address of the TCB in order for the TCP application to directly access the TCB in the table.
The TCP application may then invoke a function call to the TCP protocol stack to read the payload in the received packet. In order to retrieve the data stored in the payload in the received packet, the TCP application must read the TCB associated with the connection in order to obtain the pointer to the data in the data fragment list.
The TCP application performs the same series of operations as the TCP protocol stack. Namely, the TCP application performs the lock, read, write and unlock operation on the same TCB. The TCP application performs the lock operation on the TCB for reasons stated above. The TCP application may then read the TCB to obtain the pointer to the data stored in the data fragment list. Upon reading the data, the TCP application may write or update the TCB. For example, the TCB may be updated to update the pointer to the data fragment list. Upon writing to the TCB, the TCP application unlocks the TCB.
In certain situations, the TCP protocol stack may transmit to the transmitting network device an indication as to changes in the data fragment list after the TCP application reads data from the list. For example, the TCP protocol stack may inform the transmitting network device that the data fragment list is no longer full and that the TCP protocol stack is able to receive new packets of data from the transmitting network device.
Upon the TCP application acquiring the data from the data fragment list, the TCP application may transmit the acquired data to the processor to be processed.
Using the process described above to process an incoming TCP/IP packet results in at least 8 operations or accesses (TCP protocol stack performs 4 operations and the TCP application performs 4 operations) to the memory storing the table of TCBs. If the number of memory accesses could be reduced, the latency involved in processing a TCP/IP packet would be reduced and hence the performance of the network device could be improved.
Therefore, there is a need in the art to reduce memory accesses (transport control block accesses) in processing TCP/IP packets.